package com.funtester.seven.day7;

import com.alibaba.fastjson.JSONObject;
import com.funtester.seven.day4.HttpUtil;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class MapDemo {

    public static void main(String[] args) {
        Map<String, String> map = new HashMap<>();
        map.put("a", "aa");
        map.put("b", "bb");
        map.put("c", null);

        String p = "?";
        Set<Map.Entry<String, String>> entries = map.entrySet();
        for (Map.Entry<String, String> entry : entries) {
            String key = entry.getKey();
            String value1 = entry.getValue();
            if (value1 == null) continue;
            String value = value1.toString();
            p = p + key + "=" + HttpUtil.encode(value) + "&";
        }
        p = p.substring(0, p.length() - 1);
        System.out.println(p);


        JSONObject params = new JSONObject();
        params.put("title", map.get("title"));
        params.put("a", map.get("a"));
        params.put("price", map.get("price"));
        params.put("status", map.get("status"));
        System.out.println(params.toString());
        System.out.println(params.size());

    }

    public static JSONObject get_eventlist(Map<String, Object> m, String username) {
        String url = "HOST + GetList";


        JSONObject params = new JSONObject();
        params.put("title", m.get("title"));
        params.put("type", m.get("type"));
        params.put("price", m.get("price"));
        params.put("status", m.get("status"));


//        JSONObject response = getRes(url, params,username);
//        HttpClientUtils.outPut(response);
        return null;
    }

}
